# -- coding: utf-8 -- 
# Name: 1_3_ip4_address_conversion


import socket
from binascii import hexlify

def convert_ip4_address():
    for ip in ['127.0.0.1','192.168.86.1']:
        # 转换成打包后的32位二进制格式
        packed_ip = socket.inet_aton(ip)
        # 以十六进制形式表示二进制数据
        packed_ip = hexlify(packed_ip)
        unpacked_ip = socket.inet_ntoa(ip)
        print ip + "    " + packed_ip + "    " + unpacked_ip